import { axios } from '@/utils/request'

/**
 * api接口列表
 */
const api = {
  list: '/goods/list',
  listByIds: '/goods/listByIds',
  detail: '/goods/detail',
  add: '/goods/add',
  edit: '/goods/edit',
  delete: '/goods/delete',
  state: '/goods/state',
  asyncGoods: '/goods/syncToSon',
  skuGoods: '/goods/getGoodSkuList',
  importPost: '/goods/importPost',
  goodsUrl: '/goods/goodsUrl',
  lockUp: '/goods/lockup',
  storeList: '/store/list',
  updateField: '/goods/updateField',

  // 获取平台分类列表
  shopClassList: '/goods/shopClassList',

}


/**
 * 批量导入商品
 * @param {*} data 
 * @returns 
 */

export const importPost = (data) => axios({
  url: api.importPost,
  method: 'post',
  data
})

/**
 * 列表记录
 */
export function list(params) {
  return axios({
    url: api.list,
    method: 'get',
    params
  })
}

/**
 * 商户列表
 */
 export function storeList (params) {
  return axios({
    url: api.storeList,
    method: 'get',
    params
  })
}

/**
 * 列表记录
 */
export function skuList(params) {
  return axios({
    url: api.skuGoods,
    method: 'get',
    params
  })
}
/**
 * 根据商品ID集获取列表记录
 */
export function listByIds(goodsIds, params) {
  return axios({
    url: api.listByIds,
    method: 'get',
    params: { goodsIds, ...params }
  })
}

/**
 * 详情信息
 */
export function detail(params) {
  return axios({
    url: api.detail,
    method: 'get',
    params
  })
}

/**
 * 更新状态
 * @param {*} data
 */
export function state(data) {
  return axios({
    url: api.state,
    method: 'post',
    data
  })
}

/**
 * 新增记录
 * @param {*} data
 */
export function add(data) {
  return axios({
    url: api.add,
    method: 'post',
    data
  })
}

/**
 * 编辑记录
 * @param {*} data
 */
export function edit(data) {
  return axios({
    url: api.edit,
    method: 'post',
    data
  })
}

/**
 * 删除记录
 * @param {*} data
 */
export function deleted(data) {
  return axios({
    url: api.delete,
    method: 'post',
    data: data
  })
}
/**
 * 同步商品
 * @param {goodsIds:[],storeIds:[]} data 
 * @returns 
 */
export const asyncGoods = (data) => axios({
  url: api.asyncGoods,
  method: 'post',
  data: data
})
/**
 * 推广商品
 * @param {goodsId} data 
 * @returns 
 */
export const goodsUrl = (data) => axios({
  url: api.goodsUrl,
  method: 'post',
  data: data
})
/**
 * 批量下架
 * @param {goodsIds:[]} data 
 * @returns 
 */
export const lockUp = (data) => axios({
  url: api.lockUp,
  method: 'post',
  data: data
})
/**
 * 商品修改指定字段值
 * @param {goods_sku_id:[],field,value} data 
 * @returns 
 */
export const updateField = (data) => axios({
  url: api.updateField,
  method: 'post',
  data: data
})

  /**
 * 获取平台分类列表
 */
   export function shopClassList() {
    return axios({
      url: api.shopClassList,
      method: 'get'
    })
  }
